package stringexample;

/**
 * @License: (C) Copyright 2013-2022
 * @Contact: abcque@outlook.com
 * @IDE: IntelliJ IDEA
 * @Encoding: utf-8
 * @Project: st2214st2215
 * @Package: stringexample
 * @File: Convertor.java
 * @Time: 2023/4/4 15:26
 * @Author: abcque
 * @Description:
 * @Modifier:
 * @ModifyDate:
 * @ModifyRemark:
 */
public class Convertor {
    public static void main(String[] args) {
        String str= "123";

        int i = Integer.parseInt(str);
        System.out.println("i = " + i);

        String s = String.valueOf(i);
        System.out.println("s = " + s);

        // 字符数组转字符串
        char[] array = {'a', 'b', 'c','d'};
        String s1 = new String(array);
        System.out.println("s1 = " + s1);

        // 字符串类型转数组
        char[] chars = str.toCharArray();
        for (int x = 0; x < chars.length; x++) {
            System.out.println(chars[x]);
        }
    }
}
